#include <bits/stdc++.h>
#define LL long long
using namespace std;

LL read(){
    LL x = 0, f = 1; char ch = getchar();
    while(!isdigit(ch)){if(ch == '-')f = -1; ch = getchar();}
    while(isdigit(ch)){x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar();}
    return x * f;
}

const int maxn = 1e5 + 5;

int n, m; LL L, V;
struct Node{LL x, v, a;} a[maxn];
LL p[maxn];

vector<int> id, l[maxn];

int pw[maxn];

namespace Seg{
    LL t[maxn<<2], tag[maxn<<2], siz[maxn];
    #define ls(x) (x << 1)
    #define rs(x) (x << 1 | 1)
    void pushDown(int x){
        if(tag[x] != -1){
            t[ls(x)] = siz[ls(x)] * tag[x];
            t[rs(x)] = siz[rs(x)] * tag[x];
            tag[ls(x)] = tag[x];
            tag[rs(x)] = tag[x];
            tag[x] = -1;
        }
    }
    void pushUp(int x){
        t[x] = t[ls(x)] + t[rs(x)];
    }
    void build(int x, int l, int r){
        siz[x] = r - l + 1; tag[x] = -1; t[x] = 0;
        if(l == r) return;
        int mid = (l + r) >> 1;
        build(ls(x), l, mid); build(rs(x), mid + 1, r);
        pushUp(x);
    }
    void update(int x, int l, int r, int ql, int qr, LL v){
        if(ql <= l && r <= qr){
            tag[x] = v; t[x] = v * siz[x]; return;
        } pushDown(x);
        int mid = (l + r) >> 1;
        if(ql <= mid) update(ls(x), l, mid, ql, qr, v);
        if(mid < qr) update(rs(x), mid + 1, r, ql, qr, v);
        pushUp(x);
    }
    LL query(int x, int l, int r, int ql, int qr){
        if(ql <= l && r <= qr) return t[x];
        pushDown(x);
        int mid = (l + r) >> 1; LL res = 0;
        if(ql <= mid) res += query(ls(x), l, mid, ql, qr);
        if(mid < qr) res += query(rs(x), mid + 1, r, ql, qr);
        return res;
    }
}

LL cal(LL d, LL v, LL a){
    return 2ll * a * d + v * v;
}

void solve(){
    id.clear();
    n = read(), m = read(), L = read(), V = read();

    for(int i = 1; i <= m; i++) pw[i] = 0, l[i].clear();

    for(int i = 1; i <= n; i++)
        cin >> a[i].x >> a[i].v >> a[i].a;
    for(int i = 1; i <= m; i++)
        p[i] = read();
    sort(p + 1, p + 1 + m);
    // for(int i = 1;i<=m;i++)cout<<p[i]<<" ";cout<<"\n";
    
    LL ans = 0;
    for(int i = 1; i <= n; i++){
        if(a[i].a >= 0){
            if(a[i].x > p[m]) continue;
            if(cal(p[m] - a[i].x, a[i].v, a[i].a) > V * V) ans++, id.push_back(i);
        } else{
            if(a[i].x > p[m]) continue;
            int idx = lower_bound(p + 1, p + 1 + m, a[i].x) - p;
            if(cal(p[idx] - a[i].x, a[i].v, a[i].a) > V * V) ans++, id.push_back(i);
        }
    }
    cout << ans << " ";
    // cout << (V * V)<< "\n";


    for(auto i : id){
        // cout<<a[i].x<<":";
        // for(int j = 1; j <= n;j++)cout << cal(p[j] - a[i].x, a[i].v, a[i].a)<<" ";
        // cout << "\n";
        if(a[i].a >= 0){
            int L = lower_bound(p + 1, p + 1 + m, a[i].x) - p, R = m, mid;
            while(L < R){
                mid = (L + R) >> 1;
                if(cal(p[mid] - a[i].x, a[i].v, a[i].a) > V * V) R = mid;
                else L = mid + 1;
            }
            pw[L]++, pw[m + 1]--;
            l[m].push_back(L);
            // cout << L << " " << m << "\n";
        } else{
            int L = lower_bound(p + 1, p + 1 + m, a[i].x) - p, R = m, mid;
            int idx = L;
            while(L < R){
                mid = (L + R + 1) >> 1;
                if(cal(p[mid] - a[i].x, a[i].v, a[i].a) > V * V) L = mid;
                else R = mid - 1;
            } 
            pw[idx]++, pw[R + 1]--;
            l[R].push_back(idx);
            // cout << idx << " " << R << "\n";
        }
    }
    Seg::build(1, 1, m);
    for(int i = m; i; i--){
        sort(l[i].begin(),l[i].end());
        // cout << i << "->";
        for(auto j : l[i]){
            // cout << j << " ";
            Seg::update(1, 1, m, 1, j, 0);
            Seg::update(1, 1, m, j, j, 1);
            // cout << Seg::query(1, 1, m, 1, j)<<"..";
        }
        // cout << "\n";
    }
    cout << m - Seg::query(1, 1, m, 1, m) << "\n";
}

int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int _ = read();
    while(_--) solve();
    return 0;
}